package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.TuikuanBean;
import com.lwj.liwanjia.impl.TuikuanView;
import com.lwj.liwanjia.model.TuikuanModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/11/16.
 */

public class TuikuanPresenter {
    private TuikuanView tuikuanView;
    private TuikuanModel tuikuanModel;

    public TuikuanPresenter(TuikuanView tuikuanView) {
        this.tuikuanView = tuikuanView;
        tuikuanModel = new TuikuanModel();
    }

    public void sureTuikuan(String tradeId, String token) {
        if (tuikuanView != null) {
            tuikuanModel.sureTuikuan(tradeId, token, new Subscriber<TuikuanBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    tuikuanView.showError((Exception) e);
                }

                @Override
                public void onNext(TuikuanBean tuikuanBean) {
                    tuikuanView.sureTuikuan(tuikuanBean);
                }
            });
        }
    }
}
